<?php if (isset($add)) echo "<h2>Thêm Đối tác</h2>"; else echo "<h2>Thay đổi nội dung đối tác</h2>";?>
<form name="edit_partner" action="?act=createOrModifyPartner&partner_id=<?php echo (isset($partner_id)? $partner_id:"")  ?>" method="POST" onsubmit="return validate_values()" enctype="multipart/form-data">
	<div class='row_field'>
    	<div class='label'>
			<label for="partner_name">Tên đối tác (*):</label>
        </div>
        <div class='field'>
			<input class='inputbox' type="text" id="partner_name" name="partner_name"  value="<?php echo $partner->getname() ?>">
        </div>
	</div>
	
    <div class='row_field'>
    	<div class='label'>
			<label for="thumbnail">Hình đại diện:</label>
        </div>
		<div class='field'>
			<input class='inputbox' type="file" id="thumbnail" name="thumbnail">
        </div>
    </div>
    
    <div class='row_field'>
    	<?php
			$thm_pic = new Picture();
			$thumbnail = $partner->getthm_picture();
			if ($thumbnail) {
				$thm_pic->select($thumbnail);
			}
				
			echo "<div><img id='thm_picture' src='".$thm_pic->getPath()."'></div>"		
		?>
    </div>
    
	<div class='row_field'>
    	<div class='label'>
			<label for="description">Mô tả (*):</label>
        </div>
        <div class='field'>
			<textarea class='inputbox' id="description" name="description" rows="5"><?php echo $partner->getdescription() ?></textarea>
        </div>
	</div>

	
	
	<div class='row_field'>
	    <div class='label'>
			<label for="content">Nội dung :</label>
		</div>
		<?php
		include("../fckeditor.php");
		$sBasePath = $_SERVER['PHP_SELF'] ;
		$sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "admin" ) ) ;
		
		$oFCKeditor = new FCKeditor('content') ;
		$oFCKeditor->BasePath	= $sBasePath ;
		$oFCKeditor->Value		= $partner->getcontent();
		$oFCKeditor->Height		= 300;
		$oFCKeditor->Create() ;
		?>
	</div>
	
	<div class='row_field'>
    	<div class='label'>
			<label for="active">Hiệu lực:</label>
        </div>
        <div class='field'>
			<input type="checkbox" id="active" name="active" <?php if ($partner->getactive() == 1 || isset($add)) echo 'checked="true"'?>>
        </div>
	</div>
		
	<div class='row_field'><p>(*) Thông tin bắt buộc</p></div>
	<div class='row_field'>
		<input type="submit" value="Save">
		<input type="reset" value="Reset">
	</div>
	
</form>
<script type="text/javascript">
	function validate_values() {
		name = $('#partner_name').val();
		description = $('#description').val();
		
		message = "Các mục sau đây là bắt buộc hoặc sai giá trị: \n";
		ok = true;
		if (name == "") {
			message += "Tên đối tác \n";
			ok = false;
		}
		if (description == "") {
			message += "Mô tả đối tác \n";
			ok = false;
		}
		if (!ok) alert(message);
		return ok;
	}
</script>